package br.com.consigsys.model.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;


/**
 * The persistent class for the tcons_rubrica database table.
 * 
 */
@Entity
@Table(name="tcons_rubrica")
public class TconsRubrica extends BaseEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="ID_RUBRICA", unique=true, nullable=false)
	private Integer idRubrica;

	@Column(name="COD_RUBRICA", nullable=false, length=5)
	private String codRubrica;

    @Temporal( TemporalType.TIMESTAMP)
	@Column(name="DATA_ULT_ALTERACAO")
	private Date dataUltAlteracao;

	@Column(name="DESC_RUBRICA", nullable=false, length=30)
	private String descRubrica;

	@Column(name="USUARIO_ULT_ALTERACAO", length=150)
	private String usuarioUltAlteracao;

	private Integer versao;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ID_CONSIGNATARIA")
	private TconsConsignataria consignataria;
	
    public TconsRubrica() {
    }
    
    @PrePersist
    protected void beforePersist(){
    	this.versao = 1;
    	this.dataUltAlteracao = new Date();
    	
    }

    @PreUpdate
    protected void beforeUpdate(){
    	this.dataUltAlteracao = new Date();
    	
    }

	public Integer getIdRubrica() {
		return this.idRubrica;
	}

	public void setIdRubrica(Integer idRubrica) {
		this.idRubrica = idRubrica;
	}

	public String getCodRubrica() {
		return this.codRubrica;
	}

	public void setCodRubrica(String codRubrica) {
		this.codRubrica = codRubrica;
	}

	public Date getDataUltAlteracao() {
		return this.dataUltAlteracao;
	}

	public void setDataUltAlteracao(Date dataUltAlteracao) {
		this.dataUltAlteracao = dataUltAlteracao;
	}

	public String getDescRubrica() {
		return this.descRubrica;
	}

	public void setDescRubrica(String descRubrica) {
		this.descRubrica = descRubrica;
	}

	public String getUsuarioUltAlteracao() {
		return this.usuarioUltAlteracao;
	}

	public void setUsuarioUltAlteracao(String usuarioUltAlteracao) {
		this.usuarioUltAlteracao = usuarioUltAlteracao;
	}

	public Integer getVersao() {
		return this.versao;
	}

	public void setVersao(Integer versao) {
		this.versao = versao;
	}

	/**
	 * @return the consignataria
	 */
	public TconsConsignataria getConsignataria() {
		return consignataria;
	}

	/**
	 * @param consignataria the consignataria to set
	 */
	public void setConsignataria(TconsConsignataria consignataria) {
		this.consignataria = consignataria;
	}

	@Override
	public Integer getId() {
		return this.getIdRubrica();
	}

	@Override
	public void setId(Integer id) {
		this.setIdRubrica(id);
	}

}